package com.hibikiluler.javalearning.controller;

import com.hibikiluler.javalearning.entity.BookCollect;
import com.hibikiluler.javalearning.entity.LearnCollect;
import com.hibikiluler.javalearning.service.ItemCollectService;
import com.hibikiluler.javalearning.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/collect")
@Api(tags = "用户收藏接口")
public class ItemCollectController {

    @Autowired
    ItemCollectService itemCollectService;

    @ApiOperation(value = "查询收藏资讯")
    @GetMapping("/findcollectlearn/{userId}")
    public Result findCollectLearn(@PathVariable Long userId){
        return itemCollectService.findCollectLearn(userId);
    }

    @ApiOperation(value = "查询收藏书籍")
    @GetMapping("/findcollectbook/{userId}")
    public Result findCollectBook(@PathVariable Long userId){
        return itemCollectService.findCollectBook(userId);
    }

    @ApiOperation(value = "添加收藏资讯")
    @PostMapping("/insertcollectlearn")
    public Result insertCollectLearn(@RequestBody LearnCollect learnCollect){
        return itemCollectService.insertCollectLearn(learnCollect);
    }

    @ApiOperation(value = "添加收藏书籍")
    @PostMapping("/insertcollectbook")
    public Result insertCollectBook(@RequestBody BookCollect bookCollect){
        return itemCollectService.insertCollectBook(bookCollect);
    }

    @ApiOperation(value = "删除收藏资讯")
    @DeleteMapping("/deletecollectlearn")
    public Result deleteCollectLearn(@RequestBody LearnCollect learnCollect){
        return itemCollectService.deleteCollectLearn(learnCollect);
    }

    @ApiOperation(value = "删除收藏书籍")
    @DeleteMapping("/deletecollectbook")
    public Result deleteCollectBook(@RequestBody BookCollect bookCollect){
        return itemCollectService.deleteCollectBook(bookCollect);
    }

}
